/**
 * 获取序列号规则
 * getAQLtype
 */
import moment from 'moment';

export function getSeqNoRules() {
  return [
    {
      name: '标准代码',
      code: 'baseCode',
      value: [
        { code: 'yearCode_YY', key: '[YY]', value: '两位年份[YY]', class: '' },
        { code: 'prefixed', key: '[P]', value: '前缀', class: '' },
        { code: 'suffix', key: '[B]', value: '后缀', class: '' },
        { code: 'yearCode_Y', key: '[Y]', value: '一位年份[Y]', class: '' },
        { code: 'yearCode_YYYY', key: '[YYYY]', value: '四位年份[YYYY]', class: '' },
        { code: 'monthCode_AM', key: '[AM]', value: '一位月码[AM]', class: '' },
        { code: 'monthCode_M', key: '[M]', value: '两位月码[M]', class: '' },
        { code: 'weekCode', key: '[W]', value: '周[W]', class: '' },
        { code: 'dayCode_AD', key: '[AD]', value: '一位日码[AD]', class: '' },
        { code: 'dayCode_D', key: '[D]', value: '两位日码[D]', class: '' },
        { code: 'sequenceNo', key: '[S]', value: '流水[S]', class: '' },
        { code: 'virtureData', key: '[S]', value: '', class: '' }, //占位
        { code: 'custom_Y', key: '[CY]', value: '客户年[CY]', class: '' },
        { code: 'custom_CM', key: '[CM]', value: '客户月[CM]', class: '' },
        { code: 'custom_CYM', key: '[CYW]', value: '客户年周[CYW]', class: '' },
        { code: 'custom_CD', key: '[CD]', value: '客户日[CD]', class: '' },
        { code: 'otherCode', key: '[CPMC]', value: '产品名称[CPMC]', class: '' },
        { code: 'otherCode', key: '[CX]', value: '产线[CX]', class: '' },
        { code: 'otherCode', key: '[CPXH]', value: '产品型号[CPXH]', class: '' },
        { code: 'otherCode', key: '[GX]', value: '工序[GX]', class: '' },
        { code: 'otherCode', key: '[CPSL]', value: '产品数量[CPSL]', class: '' },
        { code: 'otherCode', key: '[CJ]', value: '车间[CJ]', class: '' },
        { code: 'yearMonthDay_YYYYMMDD', key: '[YYYYMMDD]', value: '四位年两位月两位日[YYYYMMDD]', class: 'lengthWidth' }
      ]
    },
    {
      name: '包装(原材料、成品)公用标准',
      code: 'packCode',
      value: [
        { code: '', key: '[PN]', value: '料品编码[PN]', class: '' },
        { code: '', key: '[PS]', value: '料品规格[PS]', class: '' },
        { code: '', key: '[MPV]', value: '料品版本(扩展)[MPV]', class: '' },
        { code: '', key: '[VDC]', value: '供应商(客户)代码[VDC]', class: '' },
        { code: '', key: '[VDN]', value: '供应商(客户)名称[VDN]', class: '' },
        { code: '', key: '[CPN]', value: '客户料品编码[CPN]', class: '' },
        { code: '', key: '[PQ]', value: '包装数量[PQ]', class: '' },
        { code: '', key: '[PON]', value: '采购单号[PON]', class: '' },
        { code: '', key: '[POLN]', value: '采购单项次[POLN]', class: '' },
        { code: '', key: '[VL]', value: '供应商批次[VL]', class: '' },
        { code: '', key: '[VD]', value: '生产日期[VD]', class: '' },
        { code: '', key: '[CCAT]', value: '客户物料类别码[CCAT]', class: '' },
        { code: '', key: '[CAT]', value: '物料类别码(ERP)', class: '' },
        { code: '', key: '[WO]', value: '工单号[WO]', class: '' },
        { code: '', key: '[WOLN]', value: '计划周次[WOLN]', class: '' },
        { code: '', key: '[SP]', value: '有效期[SP]', class: '' },
        { code: '', key: '[MN]', value: '模号[MN]' },
        { code: '', key: '[SIT]', value: '班次[SIT]' },
        { code: '', key: '[PNT]', value: '料品尾号[PNT]' },
        { code: '', key: '[LS]', value: '产线班次[LS]' },
        { code: '', key: '[MCPN]', value: '客户料品编码(扩展)[MCPN]', class: 'lengthWidth' },
        { code: '', key: '[RECEIVEDATE]', value: '收料日期[RECEIVEDATE]' },
        { code: '', key: '[WORKLOTNO]', value: '工单批号[WORKLOTNO]' },
        { code: '', key: '[ADDRS]', value: '地址[ADDRS]', class: '' },
        { code: '', key: '[UNIT]', value: '单位[UNIT]', class: '' },
        { code: '', key: '[SN]', value: '产品序列号[SN]', class: '' },
        { code: '', key: '[CN]', value: '箱号[CN]', class: 'lengthWidth' },
        // { code: 'virtureData', key: '[Sxxx]', value: '', class: '' }, //占位
        { code: '', key: '[PCNO]', value: '原采购订单号[PCNO]' },
        { code: '', key: '[EMCPN]', value: '成品客户料品编码(扩展)[EMCPN]', class: 'lengthWidth' }
      ]
    },
    {
      name: '自定义字符',
      code: 'customCode',
      value: []
    }
  ];
}

const getDateDefaultValue = (formatter) => {
  const date = new moment(new Date());
  return date.format(formatter);
};
const getAMOrADDefaultValue = (formatter) => {
  const date = new moment(new Date()).format(formatter);
  if (date < 10) {
    return date;
  } else {
    const strArr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
    return strArr[date - 10];
  }
};
export function getStranderCode() {
  return [
    { code: 'yearCode_YY', key: '[YY]', value: '两位年份[YY]', class: '', defaultValue: getDateDefaultValue('YY') },
    { code: 'prefixed', key: '[P]', value: '前缀[P]', class: '', defaultValue: 'A' },
    { code: 'suffix', key: '[B]', value: '后缀[B]', class: '', defaultValue: 'Z' },
    { code: 'yearCode_Y', key: '[Y]', value: '一位年份[Y]', class: '', defaultValue: getDateDefaultValue('Y') },
    { code: 'yearCode_YYYY', key: '[YYYY]', value: '四位年份[YYYY]', class: '', defaultValue: getDateDefaultValue('YYYY') },
    { code: 'monthCode_AM', key: '[AM]', value: '一位月码[AM]', class: '', defaultValue: getAMOrADDefaultValue('M') },
    { code: 'monthCode_M', key: '[M]', value: '两位月码[M]', class: '', defaultValue: getDateDefaultValue('MM') },
    { code: 'weekCode', key: '[W]', value: '周[W]', class: '', defaultValue: getDateDefaultValue('W') },
    { code: 'dayCode_AD', key: '[AD]', value: '一位日码[AD]', class: '', defaultValue: getAMOrADDefaultValue('D') },
    { code: 'dayCode_D', key: '[D]', value: '两位日码[D]', class: '', defaultValue: getDateDefaultValue('DD') },
    { code: 'sequenceNo', key: '[S]', value: '流水[S]', class: '', defaultValue: '00001' },
    { code: 'yearMonthDay_YYYYMMDD', key: '[YYYYMMDD]', value: '四位年两位月两位日[YYYYMMDD]', defaultValue: getDateDefaultValue('YYYY-MM-DD') },
    { code: 'custom_Y', key: '[CY]', value: '客户年[CY]', class: '', defaultValue: getDateDefaultValue('YYYY') },
    { code: 'custom_CM', key: '[CM]', value: '客户月[CM]', class: '', defaultValue: getDateDefaultValue('MM') },
    { code: 'custom_CYM', key: '[CYW]', value: '客户年周[CYW]', class: '', defaultValue: getDateDefaultValue('W') },
    { code: 'custom_CD', key: '[CD]', value: '客户日[CD]', class: '', defaultValue: getDateDefaultValue('DD') }
  ];
}

export function getPublicCode() {
  return [
    { code: '', key: '[PN]', value: '料品编码[PN]', class: '', defaultValue: 'PN00001' },
    { code: '', key: '[PS]', value: '料品规格[PS]', class: '', defaultValue: '10CM' },
    { code: '', key: '[MPV]', value: '料品版本(扩展)[MPV]', class: '', defaultValue: 'MPV-A001' },
    { code: '', key: '[VDC]', value: '供应商(客户)代码[VDC]', class: '', defaultValue: 'VDC-A001' },
    { code: '', key: '[VDN]', value: '供应商(客户)名称[VDN]', class: '', defaultValue: 'VDN-A001' },
    { code: '', key: '[CPN]', value: '客户料品编码[CPN]', class: '', defaultValue: 'CPN00001' },
    { code: '', key: '[PQ]', value: '包装数量[PQ]', class: '', defaultValue: '100' },
    { code: '', key: '[PON]', value: '采购单号[PON]', class: '', defaultValue: 'PO2023010100001' },
    { code: '', key: '[POLN]', value: '采购单项次[POLN]', class: '', defaultValue: '01' },
    { code: '', key: '[VL]', value: '供应商批次[VL]', class: '', defaultValue: '01' },
    { code: '', key: '[VD]', value: '生产日期[VD]', class: '', defaultValue: '20230101' },
    { code: '', key: '[CCAT]', value: '客户物料类别码[CCAT]', class: '', defaultValue: 'CCAT-A001' },
    { code: '', key: '[CAT]', value: '物料类别码(ERP)[CAT]', class: '', defaultValue: 'CAT-A001' },
    { code: '', key: '[WO]', value: '工单号[WO]', class: '', defaultValue: 'WO2023010100001' },
    { code: '', key: '[WOLN]', value: '计划周次[WOLN]', class: '', defaultValue: '01' },
    { code: '', key: '[SP]', value: '有效期[SP]', class: '', defaultValue: '20231231' },
    { code: '', key: '[MN]', value: '模号[MN]', defaultValue: 'MN-A001' },
    { code: '', key: '[SIT]', value: '班次[SIT]', defaultValue: '230101A' },
    { code: '', key: '[PNT]', value: '料品尾号[PNT]', defaultValue: 'Z' },
    { code: '', key: '[LS]', value: '产线班次[LS]', defaultValue: 'CX00001230101A' },
    { code: '', key: '[MCPN]', value: '客户料品编码(扩展)[MCPN]', class: 'lengthWidth', defaultValue: 'MCPN00001' },
    { code: '', key: '[RECEIVEDATE]', value: '收料日期[RECEIVEDATE]', defaultValue: '20230101' },
    { code: '', key: '[WORKLOTNO]', value: '工单批号[WORKLOTNO]', defaultValue: 'PH-A001' },
    { code: '', key: '[ADDRS]', value: '地址[ADDRS]', class: '', defaultValue: '440300' },
    { code: '', key: '[UNIT]', value: '单位[UNIT]', class: '', defaultValue: 'CM' },
    { code: '', key: '[SN]', value: '产品序列号[SN]', class: '', defaultValue: 'SN00001' },
    { code: '', key: '[CN]', value: '箱号[CN]', class: 'lengthWidth', defaultValue: '0001' },
    { code: '', key: '[PCNO]', value: '原采购订单号[PCNO]', defaultValue: 'OPO2023010100001' },
    { code: '', key: '[EMCPN]', value: '成品客户料品编码(扩展)[EMCPN]', class: 'lengthWidth', defaultValue: 'EMCPN00001' },
    { code: '', key: '[WORKMODEL]', value: '工单机型[WORKMODEL]', class: 'lengthWidth', defaultValue: '0001-01' },
    { code: '', key: '[PV]', value: '料品版本[PV]', class: 'lengthWidth', defaultValue: '1.1' },
    { key: '[BRAND]', value: '物料品牌[BRAND]', defaultValue: 'BRAND' },
    { key: '[IL]', value: '检验批次[IL]', defaultValue: '01' },
    { key: '[DC]', value: 'D/C[DC]', defaultValue: getDateDefaultValue('YYYY-MM-DD') }
  ];
}
export const subTypeMap = {
  WORKORDER: '工单',
  FLOW_CARD: '流程卡',
  WAREHOUSE: '仓库',
  WORKSTATION: '产线（工位）',
  STORAGE_AREA: '存储区域',
  EQUIPEMENT: '设备及其属性',
  TOOL: '工装/夹具',
  VEHICLE: '载具',
  INSPECTION_RESULTS: '检验结果',
  FAULT_PHENOMENON: '故障现象/故障类别',
  RAW_MATERIAL_PACKAGING: '原材料包装',
  WORK_IN_PROGRESS: '在制品',
  FINISHED_PRODUCT_PACKAGING: '成品包装',
  ACCESSORIES: '辅料',
  PALLET: '栈板',
  SCM_DO: 'SCM送货单',
  NG: '故障',
  // 没人告知过这个规则  看记录自己加的
  'RULE-SCHEMA_SN_DEFINITION': '仓库业务规则序列号规则'
};

export function getOtherCode(xl) {
  const rules = {
    //工单
    workorder: [
      // { key: '[WO]', value: '工单号' },
      // { key: '[CPBM]', value: '产品编码' },
      // { key: '[CPXH]', value: '产品型号' },
      { key: '[CPMC]', value: '产品名称[CPMC]', defaultValue: 'CP-A001' },
      { key: '[CPSL]', value: '产品数量[CPSL]', defaultValue: '100' },
      { key: '[CJ]', value: '车间[CJ]', defaultValue: 'CJ00001' },
      { key: '[CX]', value: '产线[CX]', defaultValue: 'CX00001' }
    ],
    // 流程卡
    flow_card: [
      // { key: '[WO]', value: '工单号' },
      // { key: '[CPBM]', value: '产品编码' },
      // { key: '[CPXH]', value: '产品型号' },

      { key: '[CPMC]', value: '产品名称[CPMC]', defaultValue: 'CP-A001' },
      { key: '[CPSL]', value: '产品数量[CPSL]', defaultValue: '100' },
      { key: '[CJ]', value: '车间[CJ]', defaultValue: 'CJ00001' },
      { key: '[CX]', value: '产线[CX]', defaultValue: 'CX00001' }
    ],
    //仓库
    warehouse: [
      { key: '[CKMC]', value: '仓库名称[CKMC]', defaultValue: 'CK-A001' },
      { key: '[CKBM]', value: '仓库编码[CKBM]', defaultValue: 'CK00001' },
      { key: '[CKLX]', value: '仓库类型[CKLX]', defaultValue: 'CKLX-A001' },
      { key: '[WLCCLX]', value: '物料存储类型[WLCCLX]', defaultValue: 'WLCCLX-A001' },
      { key: '[YSBS]', value: '颜色标识[YSBS]', defaultValue: '#FFFFFF ' }
    ],
    //产线（工位）
    workstation: [
      { key: '[CXMC]', value: '产线名称[CXMC]', defaultValue: 'CX-A001' },
      { key: '[CXBM]', value: '产线编码[CXBM]', defaultValue: 'CX00001' },
      { key: '[SSCJ]', value: '所属车间[SSCJ]', defaultValue: 'CJ00001' },
      { key: '[CXZT]', value: '产线状态[CXZT]', defaultValue: 'WORK' },
      { key: '[CXRJHSL]', value: '产线日计划数量[CXRJHSL]', defaultValue: '1000' },
      { key: '[XZ]', value: '线长[XZ]', defaultValue: 'admin' },
      { key: '[GCRY]', value: '工程人员[GCRY]', defaultValue: 'admin' },
      { key: '[IPQCXJRY]', value: 'IPQC巡检人员[IPQCXJRY]', defaultValue: 'admin' },
      { key: '[GWMC]', value: '工位名称[GWMC]', defaultValue: 'GW-A001' },
      { key: '[GWBM]', value: '工位编码[GWBM]', defaultValue: 'GW00001,defaulutValue' }
    ],
    //存储区域
    storage_area: [
      { key: '[CCQYMC]', value: '存储区域名称[CCQYMC]', defaultValue: 'CCQY-A001' },
      { key: '[CCQYBM]', value: '存储区域编码[CCQYBM]', defaultValue: 'CCQY00001' },
      { key: '[CCQYLX]', value: '存储区域类型[CCQYLX]', defaultValue: 'CCQYLX-A001' },
      { key: '[WLCCLX]', value: '物料存储类型[WLCCLX]', defaultValue: 'WLCCLX-A001' },
      { key: '[YSBS]', value: '颜色标识[YSBS]', defaultValue: '#FFFFFF' }
    ],
    //设备及其属性
    equipement: [
      { key: '[SBBM]', value: '设备编码[SBBM]', defaultValue: 'SB00001' },
      { key: '[SBMC]', value: '设备名称[SBMC]', defaultValue: 'SB-A001' },
      { key: '[SBLX]', value: '设备类型[SBLX]', defaultValue: 'SBLX-A001' },
      { key: '[SBXH]', value: '设备型号[SBXH]', defaultValue: 'SBXH-A001' },
      { key: '[SBGG]', value: '设备规格[SBGG]', defaultValue: '10CM' },
      { key: '[SBZT]', value: '设备状态[SBZT]', defaultValue: 'WORK' },
      { key: '[FZBM]', value: '负责部门[FZBM]', defaultValue: 'PRODUCTION DEPARTMENT' },
      { key: '[FZRY]', value: '负责人员[FZRY]', defaultValue: 'admin' },
      { key: '[SZCJ]', value: '所在车间[SZCJ]', defaultValue: 'CJ00001' },
      { key: '[SZCX]', value: '所在产线[SZCX]', defaultValue: 'CX00001' },
      { key: '[IPDZ]', value: 'IP地址[IPDZ]', defaultValue: '123.123.0.123' },
      { key: '[DK]', value: '端口[DK]', defaultValue: '1023' },
      { key: '[CZJMC]', value: '主机名称[CZJMC]', defaultValue: 'WIN-ABCD123ABCD' },
      { key: '[WLXYLX]', value: '网络协议类型[WLXYLX]', defaultValue: 'ICMP' },
      { key: '[BZGS]', value: '标准工时[BZGS] ', defaultValue: '8' }
    ],
    //工装/夹具
    tool: [
      { key: '[GZJJBM]', value: '工装/夹具编码[GZJJBM]', defaultValue: 'GZJJ00001' },
      { key: '[GZJJMC]', value: '工装/夹具名称[GZJJMC]', defaultValue: 'GZJJ-A001' },
      { key: '[GZJJLX]', value: '工装/夹具类型[GZJJLX]', defaultValue: 'GZJJLX-A001' },
      { key: '[GZJJXH]', value: '工装/夹具型号[GZJJXH]', defaultValue: 'GZJJXH-A001' },
      { key: '[GZJJGG]', value: '工装/夹具规格[GZJJGG]', defaultValue: '10CM' },
      { key: '[GZJJZT]', value: '工装/夹具状态[GZJJZT]', defaultValue: 'WORK' },
      { key: '[FZBM]', value: '负责部门[FZBM]', defaultValue: 'PRODUCTION DEPARTMENT' },
      { key: '[FZRY]', value: '负责人员[FZRY]', defaultValue: 'admin' },
      { key: '[SZCJ]', value: '所在车间[SZCJ]', defaultValue: 'CJ00001' },
      { key: '[SZCX]', value: '所在产线[SZCX]', defaultValue: 'CX00001' }
    ],
    //载具
    vehicle: [
      { key: '[ZJBM]', value: '载具编码[ZJBM]', defaultValue: 'ZJ00001' },
      { key: '[ZJMC]', value: '载具名称[ZJMC]', defaultValue: 'ZJ-A001' },
      { key: '[ZJLX]', value: '载具类型[ZJLX]', defaultValue: 'ZJLX-A001' },
      { key: '[ZJXH]', value: '载具型号[ZJXH]', defaultValue: 'ZJXH-A001' },
      { key: '[ZJGG]', value: '载具规格[ZJGG]', defaultValue: '10CM' },
      { key: '[ZJZZ]', value: '载具状态[ZJZZ]', defaultValue: 'WORK' },
      { key: '[FZBM]', value: '负责部门[FZBM]', defaultValue: 'PRODUCTION DEPARTMENT' },
      { key: '[FZRY]', value: '负责人员[FZRY]', defaultValue: 'admin' },
      { key: '[SZCJ]', value: '所在车间[SZCJ]', defaultValue: 'CJ00001' },
      { key: '[SZCX]', value: '所在产线[SZCX]', defaultValue: 'CX00001' }
    ],
    //检验结果
    inspection_results: [
      { key: '[JYDH]', value: '检验单号[JYDH]', defaultValue: 'IQC2023010100001' },
      { key: '[JYLX]', value: '检验类型[JYLX]', defaultValue: 'IQC' },
      { key: '[JYFS]', value: '检验方式[JYFS]', defaultValue: 'FULL INSPECTION' },
      { key: '[JYSL]', value: '检验数量[JYSL]', defaultValue: '100' },
      { key: '[JYRY]', value: '检验人员[JYRY]', defaultValue: 'admin' },
      { key: '[JYJG]', value: '检验结果[JYJG]', defaultValue: 'PASS' },
      { key: '[JYRQ]', value: '检验日期[JYRQ]', defaultValue: '20230101' }
    ],
    //故障现象/故障类别
    fault_phenomenon: [
      { key: '[JYDH]', value: '检验单号[JYDH]', defaultValue: 'IQC2023010100001' },
      { key: '[JYLX]', value: '检验类型[JYLX]', defaultValue: 'IQC' },
      { key: '[JYFS]', value: '检验方式[JYFS]', defaultValue: 'FULL INSPECTION' },
      { key: '[JYSL]', value: '检验数量[JYSL]', defaultValue: '100' },
      { key: '[JYRY]', value: '检验人员[JYRY]', defaultValue: 'admin' },
      { key: '[JYJG]', value: '检验结果[JYJG]', defaultValue: 'PASS' },
      { key: '[JYRQ]', value: '检验日期[JYRQ]', defaultValue: '20230101' },
      { key: '[BLDM]', value: '不良代码[BLDM]', defaultValue: 'BLDM-A001' },
      { key: '[BLXXMS]', value: '不良现象描述[BLXXMS]', defaultValue: 'DEFECT' },
      { key: '[BLYY]', value: '不良原因[BLYY]', defaultValue: 'BLYY-A001' },
      { key: '[CLLX]', value: '处理类型[CLLX]', defaultValue: 'NORMAL' }
    ],
    //原材料包装
    raw_material_packaging: [
      // { key: '[WLBM]', value: '物料编码' },
      // { key: '[WLXH]', value: '物料型号' },
      // { key: '[WLBB]', value: '物料版本' },
      { key: '[WLLB]', value: '物料类别[WLLB]', defaultValue: 'WLLB-A001' },
      { key: '[WLMC]', value: '物料名称[WLMC]', defaultValue: 'WL-A001' },
      { key: '[CJMC]', value: '厂家名称[CJMC]', defaultValue: 'CJ-A001' },
      { key: '[CJWLXH]', value: '厂家物料型号[CJWLXH]', defaultValue: 'CJWLXH-A001' },
      { key: '[JHDJ]', value: '进货单价[JHDJ]', defaultValue: '100' },
      { key: '[UNIT]', value: '单位[UNIT]', defaultValue: 'CM' },
      { key: '[SL]', value: '数量[SL]', defaultValue: '1000' },
      { key: '[HEIGHT]', value: '长度[HEIGHT]', defaultValue: '100' },
      { key: '[GD]', value: '高度[GD]', defaultValue: '100' },
      { key: '[BZQTS]', value: '保质期天数[BZQTS]', defaultValue: '365' }
    ],
    //在制品
    work_in_progress: [
      // { key: '[WO]', value: '工单号' },
      // { key: '[CPBM]', value: '产品编码' },
      { key: '[CPMC]', value: '产品名称[CPMC]', defaultValue: 'CP-A001' },
      { key: '[CPXH]', value: '产品型号[CPXH]', defaultValue: 'CP-A001' },
      { key: '[CPSL]', value: '产品数量[CPSL]', defaultValue: 'CP-A001' },
      { key: '[CJ]', value: '车间[CJ]', defaultValue: 'CJ00001' },
      { key: '[CX]', value: '产线[CX]', defaultValue: 'CX00001' },
      { key: '[GX]', value: '工序[GX]', defaultValue: 'GX00001' }
    ],
    //成品包装
    finished_product_packaging: [
      // { key: '[WO]', value: '工单号' },
      // { key: '[CPBM]', value: '产品编码' },
      // { key: '[CPXH]', value: '产品型号' },
      // { key: '[YCLGYS]', value: '原材料供应商名称' },
      { key: '[CPMC]', value: '产品名称[CPMC]', defaultValue: 'CP-A001' },
      { key: '[CPSL]', value: '产品数量[CPSL]', defaultValue: '1000' },
      { key: '[CJ]', value: '车间[CJ]', defaultValue: 'CJ00001' },
      { key: '[CX]', value: '产线[CX]', defaultValue: 'CX00001' },
      { key: '[GX]', value: '工序[GX]', defaultValue: 'GX00001' },
      { key: '[SBBM]', value: '设备编码[SBBM]', defaultValue: 'SB00001' }
    ],
    //辅料
    accessories: [
      // { key: '[WLBM]', value: '物料编码' },
      // { key: '[WLXH]', value: '物料型号' },
      // { key: '[WLBB]', value: '物料版本' },
      // { key: '[CJMC]', value: '厂家名称', defaultValue: 'CJWLXH-A001' },
      { key: '[WLLB]', value: '物料类别[WLLB]', defaultValue: 'WLLB-A001' },
      { key: '[WLMC]', value: '物料名称[WLMC]', defaultValue: 'WL-A001' },
      { key: '[CJWLXH]', value: '厂家物料型号[CJWLXH]', defaultValue: 'CJWLXH-A001' },
      { key: '[JHDJ]', value: '进货单价[JHDJ]', defaultValue: '100' },
      { key: '[UNIT]', value: '单位[UNIT]', defaultValue: 'CM' },
      { key: '[KHLH]', value: '客户料号[KHLH]', defaultValue: 'KHLH-A001' },
      { key: '[SL]', value: '数量[SL]', defaultValue: '1000' },
      { key: '[HEIGHT]', value: '长度[HEIGHT]', defaultValue: '100' },
      { key: '[GD]', value: '高度[GD]', defaultValue: '100' },
      { key: '[KD]', value: '宽度[KD]', defaultValue: '100' },
      { key: '[SBBM]', value: '设备编码[SBBM]', defaultValue: 'SB00001' },
      { key: '[BZQTS]', value: '保质期天数[BZQTS]', defaultValue: '365' }
    ],
    // 栈板
    pallet: [
      { key: '[ZBBM]', value: '栈板编码[ZBBM]', defaultValue: 'ZB00001' },
      { key: '[ZBMC]', value: '栈板名称[ZBMC]', defaultValue: 'ZB-A001' },
      { key: '[ZBLX]', value: '栈板类型[ZBLX]', defaultValue: 'ZBLX-A001' },
      { key: '[ZBXH]', value: '栈板型号[ZBXH]', defaultValue: 'ZBXH-A001' },
      { key: '[ZBGG]', value: '栈板规格[ZBGG]', defaultValue: '10CM' },
      { key: '[ZBZT]', value: '栈板状态[ZBZT]', defaultValue: 'WORK' },
      { key: '[FZBM]', value: '负责部门[FZBM]', defaultValue: 'PRODUCTION DEPARTMENT' },
      { key: '[FZRY]', value: '负责人员[FZRY]', defaultValue: 'admin' },
      { key: '[SZCJ]', value: '所在车间[SZCJ]', defaultValue: 'CJ00001' },
      { key: '[SZCX]', value: '所在产线[SZCX]', defaultValue: 'CX00001' }
    ]
  };
  if (xl) {
    return rules[xl];
  } else {
    return rules;
  }
}
function arrayToKeyValue(array) {
  return array.reduce((result, item) => {
    result[item.key] = item.defaultValue;
    return result;
  }, {});
}

function otherCodeToKeyValue(obj) {
  const keyValueObject = {};
  for (const category in obj) {
    const categoryData = obj[category];
    for (const item of categoryData) {
      keyValueObject[item.key] = item.defaultValue;
    }
  }
  return keyValueObject;
}

export const getKeyValueMap = () => {
  const standMap = arrayToKeyValue(getStranderCode());
  const publicMap = arrayToKeyValue(getPublicCode());
  const otherMap = otherCodeToKeyValue(getOtherCode());
  return {
    ...standMap,
    ...publicMap,
    ...otherMap
  };
};

getKeyValueMap();
